﻿//////////////////////////////////////////////////////////////////////////////
//
//  Copyright © 1998-2024 Glodon Company Limited.  All rights reserved.
//
//  Use of this software is subject to the terms of the Glodon license
//  agreement provided at the time of installation or download, or which
//  otherwise accompanies this software in either electronic or hard copy form.  
//
//////////////////////////////////////////////////////////////////////////////

#include <QDialog>
#include <QLineEdit>
#include <QComboBox>
#include <QTableWidget>
#include <QListWidget>
#include <QScrollArea>
#include <QGroupBox>
#include "GmepUIBase.h"

#define QTOOLTIP_POSITION_X   20
#define QTOOLTIP_POSITION_Y   -30
#define LINE_EDIT_INVALID   "QLineEdit{border:1px solid red }"
#define COMBO_BOX_INVALID   "QComboBox{border:1px solid red }"
#define TABLE_WIDGET_INVALID "QTableWidget{border:1px solid red }"
#define LIST_WIDGET_INVALID  "QListWidget{border:1px solid red }"
#define SCROLL_AREA_INVALID "QScrollArea{border:1px solid red }"
#define WIDGET_INVALID "QWidget{border:1px solid red }"

#define GROUP_BOX_INVALID "QGroupBox{border:1px solid red }"
#define EDIT_SHEET "border:1px solid green"

struct UserValidatorData : QObjectUserData {
    QValidator * validate;
};

struct UserTableColumnAllowNullData : QObjectUserData {
    std::vector<bool> IsAllowNull;
};

class GMEP_UI_BASE_EXPORT QtFormNullValidator
{

public:
    static QtFormNullValidator &GetInstance();
    static bool NullValueCheck(const QObjectList list);
    static bool NullValueCheck(const QWidget* widget);

    static bool QLineEdit_IsEmpty(QLineEdit * qlineEdit);
    static bool QComboBox_IsEmpty(QComboBox * qComboBox);
    static bool QTableWidget_IsEmpty(QTableWidget * qtableWidget);
    static bool QListWidget_IsEmpty(QListWidget * qlistWidget);


    //自定义为空样式
    static void QScrollArea_IsEmptySheet(QScrollArea * qscrollArea, bool IsInValid);
    static void QGroupBox_IsEmptySheet(QGroupBox * qgroupBox, bool IsInValid);

private:
    QtFormNullValidator();
    ~QtFormNullValidator();

private:
    //QDialog * m_dialog;
    static QStringList dataTypeList;
};

